🎖️GitЯра🎖️
Node / meshtastic / Meshtastic-Android / files / core / repository / src / commonMain / kotlin / org / meshtastic / core / repository / MeshLogRetention.kt
Displaying Raw • Download
core/repository/src/commonMain/kotlin/org/meshtastic/core/repository/MeshLogRetention.kt bc4e9da3ad7a2a22768cbaecc75810e018bc40e2 (bc4e9da3) Text, 1.89 KB
T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.core.repository
Tff7b72import T7ee787kotlin.time.Duration
Tff7b72import T7ee787kotlin.time.Duration.Companion.days
Tff7b72import T7ee787kotlin.time.Duration.Companion.hours
T8b949e/**
* Decodes [MeshLogPrefs.retentionDays], which overloads two sentinels onto the day count: [KEEP_FOREVER] never prunes
* and [ONE_HOUR] keeps only the last hour.
*
* Both sentinels are real user selections rather than "unset", so pruning callers must resolve the window here instead
* of treating the setting as a plain day count.
*/
Tff7b72object T56d364MeshLogRetention Tb4b4b4{
T8b949e/** Retention setting for "never delete". */
Tff7b72const Tff7b72val Te6edf3KEEP_FOREVERTb4b4b4: Tffa657Int Tff7b72= T79c0ff0
T8b949e/** Retention setting for "keep the last hour", which cannot be expressed as a whole number of days. */
Tff7b72const Tff7b72val Te6edf3ONE_HOURTb4b4b4: Tffa657Int Tff7b72= Tff7b72-T79c0ff1
T8b949e/** The retention window for [retentionDays], or `null` when logs are never pruned. */
Tff7b72fun Td2a8ffwindowOrNullTb4b4b4(Te6edf3retentionDaysTb4b4b4: Tffa657IntTb4b4b4)Tb4b4b4: Te6edf3Duration? Tff7b72= Tff7b72when Tb4b4b4{
Te6edf3retentionDays Tff7b72=Tff7b72= Te6edf3KEEP_FOREVER Tff7b72-Tff7b72> Tff7b72null
T8b949e// Every negative value resolves to the one-hour sentinel; scaling one by days would put the cutoff in the
T8b949e// future, matching the whole table.
Te6edf3retentionDays Tff7b72< T79c0ff0 Tff7b72-Tff7b72> T79c0ff1.Te6edf3hours
Tff7b72else Tff7b72-Tff7b72> Te6edf3retentionDaysTb4b4b4.Te6edf3days
Tb4b4b4}
Tb4b4b4}
Served by rngit 1.5.0 - Generated in 0.05s